package juc.syncup;

import org.openjdk.jol.info.ClassLayout;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2022-09-05 22:56
 **/
public class SynchronizedUpDemo {
    public static void main(String[] args) {
        final Object o = new Object();
        o.hashCode();
        System.out.println(ClassLayout.parseInstance(o).toPrintable());

        System.out.println("====================");
        new Thread(()->{
            synchronized (o) {
                System.out.println(ClassLayout.parseInstance(o).toPrintable());
            }
        }).start();
    }

    private static void noLock() {
        final Object o = new Object();
        final int hashCode = o.hashCode();
        System.out.println("10进制：" + hashCode);
        System.out.println("16进制：" + Integer.toHexString(hashCode));
        System.out.println("2进制：" + Integer.toBinaryString(hashCode));
        System.out.println(ClassLayout.parseInstance(o).toPrintable());
    }
}
